package cn.itcast.up.common2

import com.typesafe.config
import com.typesafe.config.ConfigFactory


case class Config
  (
    model: Model,
    hadoop: Hadoop,
    mysql: MySQL,
    oozie: Oozie
  )

  case class Model
  (
    user: String,
    app: String,
    path: Path
  )

  case class Path
  (
    jars: String,
    modelBase: String
  )

  case class Hadoop
  (
    nameNode: String,
    resourceManager: String
  )

  case class MySQL
  (
    url: String,
    driver: String,
    tagTable: String,
    modelTable: String
  )

  case class Oozie
  (
    url: String,
    params: Map[String, String]
  )
object UpHolder {
  import pureconfig._
  import pureconfig.generic.auto._
  private val configTools = ConfigFactory.load("up")
  val config: Config = ConfigSource.fromConfig(configTools).load[Config].right.get
  val model: Model = config.model
  val hadoop: Hadoop = config.hadoop
  val mysql: MySQL = config.mysql
  val oozie: Oozie = config.oozie

}
